<template>
  <div>
    <HeadNav type="main"></HeadNav>
    <div class="login">
      <div class="login-form">
        <div class="title">
<!--          <img style="width: 30px;height: 30px;border-radius: 5px" src="../../assets/logo.png">-->
          <div style="margin-left: 10px;font-size: 18px;font-weight: bold">
            开启索存
          </div>
        </div>
        <div class="login-form-item">
          <div>账号</div>
          <input v-model="loginForm.tel" style="height: 30px"/>
        </div>
        <div class="login-form-item">
          <div>密码</div>
          <input v-model="loginForm.password" style="height: 30px" type="password"/>
        </div>
        <div class="login-form-button">
          <button @click="login" style="background-color: white;height: 40px;width: 100px;border-radius: 5px">登录</button>
        </div>
        <div class="toLogin" style="margin-top: 20px;text-decoration:underline;font-size: 12px;margin-bottom: 20px" @click="$router.push({name:'register'})">还没账号？前往注册</div>
      </div>
    </div>

    <CopyrightInformation style="position: fixed;bottom: 20px;left: 500px"></CopyrightInformation>

  </div>
</template>

<script>
import HeadNav from "@/components/HeadNav";
import CopyrightInformation from "@/components/CopyrightInformation.vue";
import constants from "@/utils/constants";

export default {
  name: "LoginView",
  components:{
    HeadNav,CopyrightInformation
  },
  data() {
    return {
      loginForm: {
        tel:"",
        password:""
      }
    }
  },
  methods: {
    login(){
      this.$api.login(this.loginForm).then(res=>{
        window.localStorage.setItem(constants.ACCESS_TOKEN,res.data)
        this.$router.push({
          name:'home'
        })
      })
    }
  },
}
</script>

<style scoped lang="scss">

.login{
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;

  .login-form{
    margin-top: 200px;
    width: 350px;
    background-color: #2c2c2c;
    border-radius: 5px;

    display: flex;
    flex-direction: column;
    align-items: center;
    color: white;

    .title{
      margin-top: 20px;
      display: flex;
      flex-direction: row;
      align-items: center;
    }

    .login-form-item{
      margin-top: 20px;
      font-size: 14px;
      display: flex;
      flex-direction: row;
      width: 210px;
      justify-content: space-between;
      align-items: center;
    }

    .login-form-button{
      margin-top: 20px;
    }

    .toLogin:hover{
      cursor: pointer;
    }
  }
}
</style>
